#include <iostream>
#include <vector>
#include <string>
using namespace std;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
void dfs(int i,int j,vector<string>& path,vector<string>& ans,vector<vector<int>>& maze)
{
    if(i==maze.size()-1&&j==maze[0].size()-1)
    {
        string s;
        s="("+to_string(i)+","+to_string(j)+")";
        path.push_back(s);
        ans=path;
    }
    if(maze[i][j]==0)
    {
        string s;
        s="("+to_string(i)+","+to_string(j)+")";
        path.push_back(s);
        for(int k=0;k<4;k++)
        {
            int x=i+dx[k];
            int y=j+dy[k];
            if(x>=0&&x<maze.size()&&y>=0&&y<maze[0].size()&&maze[x][y]==0)
            {
                maze[i][j]=1;
                dfs(x,y,path,ans,maze);
                path.pop_back();
                maze[i][j]=0;

            }
        }
    }
}
int main()
{
    int m,n;
    cin >>m>>n; 
    vector<vector<int>> maze(m,vector<int>(n));
    vector<string> path;
    vector<string> ans;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>maze[i][j];
        }
    }
    
    dfs(0,0,path,ans,maze);
    for(auto& e:ans)
    {
        cout << e<<endl;
    }
    return 0;
}